#include "WebPageSearcher.h"
#include "SplitTool.h"

WebPageSearcher::WebPageSearcher(const string &query, const TcpConnectionPtr &con)
    : _queryWord(query), _conn(con) {}

void WebPageSearcher::start() {
    Configuration *conf = Configuration::getInstance();
    conf->setConfigMap("/home/kyle/Project/WebDisk/conf/myconf.conf");
    // std::cout << "创建conf实例成功\n";
    SplitToolCppJieba cuttor(conf);
    WebPageQuery query_result(_queryWord, &cuttor);

    string str_result = query_result.doQuery();
    // std::cout << "查询成功，即将给客户端发送信息\n";
    _conn->sendInLoop(str_result);
    std::cout << "发送信息完成\n";
}